3.2.14 \(\int \frac {\sin ^2(a+\frac {b}{x})}{x} \, dx\) [114]

Optimal. Leaf size=37 \[ \frac {1}{2} \cos (2 a) \text {Ci}\left (\frac {2 b}{x}\right )+\frac {\log (x)}{2}-\frac {1}{2} \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right ) \]

[Out]

1/2*Ci(2*b/x)*cos(2*a)+1/2*ln(x)-1/2*Si(2*b/x)*sin(2*a)

________________________________________________________________________________________

Rubi [A]
time = 0.03, antiderivative size = 37, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, integrand size = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3506, 3459, 3457, 3456} \begin {gather*} \frac {1}{2} \cos (2 a) \text {CosIntegral}\left (\frac {2 b}{x}\right )-\frac {1}{2} \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right )+\frac {\log (x)}{2} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Sin[a + b/x]^2/x,x]

[Out]

(Cos[2*a]*CosIntegral[(2*b)/x])/2 + Log[x]/2 - (Sin[2*a]*SinIntegral[(2*b)/x])/2

Rule 3456

Int[Sin[(d_.)*(x_)^(n_)]/(x_), x_Symbol] :> Simp[SinIntegral[d*x^n]/n, x] /; FreeQ[{d, n}, x]

Rule 3457

Int[Cos[(d_.)*(x_)^(n_)]/(x_), x_Symbol] :> Simp[CosIntegral[d*x^n]/n, x] /; FreeQ[{d, n}, x]

Rule 3459

Int[Cos[(c_) + (d_.)*(x_)^(n_)]/(x_), x_Symbol] :> Dist[Cos[c], Int[Cos[d*x^n]/x, x], x] - Dist[Sin[c], Int[Si
n[d*x^n]/x, x], x] /; FreeQ[{c, d, n}, x]

Rule 3506

Int[((e_.)*(x_))^(m_.)*((a_.) + (b_.)*Sin[(c_.) + (d_.)*(x_)^(n_)])^(p_), x_Symbol] :> Int[ExpandTrigReduce[(e
*x)^m, (a + b*Sin[c + d*x^n])^p, x], x] /; FreeQ[{a, b, c, d, e, m, n}, x] && IGtQ[p, 0]

Rubi steps

\begin {align*} \int \frac {\sin ^2\left (a+\frac {b}{x}\right )}{x} \, dx &=\int \left (\frac {1}{2 x}-\frac {\cos \left (2 a+\frac {2 b}{x}\right )}{2 x}\right ) \, dx\\ &=\frac {\log (x)}{2}-\frac {1}{2} \int \frac {\cos \left (2 a+\frac {2 b}{x}\right )}{x} \, dx\\ &=\frac {\log (x)}{2}-\frac {1}{2} \cos (2 a) \int \frac {\cos \left (\frac {2 b}{x}\right )}{x} \, dx+\frac {1}{2} \sin (2 a) \int \frac {\sin \left (\frac {2 b}{x}\right )}{x} \, dx\\ &=\frac {1}{2} \cos (2 a) \text {Ci}\left (\frac {2 b}{x}\right )+\frac {\log (x)}{2}-\frac {1}{2} \sin (2 a) \text {Si}\left (\frac {2 b}{x}\right )\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.04, size = 32, normalized size = 0.86 \begin {gather*} \frac {1}{2} \left (\cos (2 a) \text {Ci}\left (\frac {2 b}{x}\right )+\log (x)-\sin (2 a) \text {Si}\left (\frac {2 b}{x}\right )\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Sin[a + b/x]^2/x,x]

[Out]

(Cos[2*a]*CosIntegral[(2*b)/x] + Log[x] - Sin[2*a]*SinIntegral[(2*b)/x])/2

________________________________________________________________________________________

Maple [A]
time = 0.05, size = 36, normalized size = 0.97

method result size
derivativedivides \(-\frac {\ln \left (\frac {b}{x}\right )}{2}-\frac {\sinIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )}{2}+\frac {\cosineIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )}{2}\) \(36\)
default \(-\frac {\ln \left (\frac {b}{x}\right )}{2}-\frac {\sinIntegral \left (\frac {2 b}{x}\right ) \sin \left (2 a \right )}{2}+\frac {\cosineIntegral \left (\frac {2 b}{x}\right ) \cos \left (2 a \right )}{2}\) \(36\)
risch \(\frac {i {\mathrm e}^{-2 i a} \pi \,\mathrm {csgn}\left (\frac {b}{x}\right )}{4}-\frac {i {\mathrm e}^{-2 i a} \sinIntegral \left (\frac {2 b}{x}\right )}{2}-\frac {{\mathrm e}^{-2 i a} \expIntegral \left (1, -\frac {2 i b}{x}\right )}{4}-\frac {{\mathrm e}^{2 i a} \expIntegral \left (1, -\frac {2 i b}{x}\right )}{4}+\frac {\ln \left (x \right )}{2}\) \(68\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(a+b/x)^2/x,x,method=_RETURNVERBOSE)

[Out]

-1/2*ln(b/x)-1/2*Si(2*b/x)*sin(2*a)+1/2*Ci(2*b/x)*cos(2*a)

________________________________________________________________________________________

Maxima [C] Result contains complex when optimal does not.
time = 0.34, size = 51, normalized size = 1.38 \begin {gather*} \frac {1}{4} \, {\left ({\rm Ei}\left (\frac {2 i \, b}{x}\right ) + {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \cos \left (2 \, a\right ) + \frac {1}{4} \, {\left (i \, {\rm Ei}\left (\frac {2 i \, b}{x}\right ) - i \, {\rm Ei}\left (-\frac {2 i \, b}{x}\right )\right )} \sin \left (2 \, a\right ) + \frac {1}{2} \, \log \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)^2/x,x, algorithm="maxima")

[Out]

1/4*(Ei(2*I*b/x) + Ei(-2*I*b/x))*cos(2*a) + 1/4*(I*Ei(2*I*b/x) - I*Ei(-2*I*b/x))*sin(2*a) + 1/2*log(x)

________________________________________________________________________________________

Fricas [A]
time = 0.36, size = 39, normalized size = 1.05 \begin {gather*} \frac {1}{4} \, {\left (\operatorname {Ci}\left (\frac {2 \, b}{x}\right ) + \operatorname {Ci}\left (-\frac {2 \, b}{x}\right )\right )} \cos \left (2 \, a\right ) - \frac {1}{2} \, \sin \left (2 \, a\right ) \operatorname {Si}\left (\frac {2 \, b}{x}\right ) + \frac {1}{2} \, \log \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)^2/x,x, algorithm="fricas")

[Out]

1/4*(cos_integral(2*b/x) + cos_integral(-2*b/x))*cos(2*a) - 1/2*sin(2*a)*sin_integral(2*b/x) + 1/2*log(x)

________________________________________________________________________________________

Sympy [A]
time = 1.35, size = 31, normalized size = 0.84 \begin {gather*} \frac {\log {\left (x \right )}}{2} - \frac {\sin {\left (2 a \right )} \operatorname {Si}{\left (\frac {2 b}{x} \right )}}{2} + \frac {\cos {\left (2 a \right )} \operatorname {Ci}{\left (\frac {2 b}{x} \right )}}{2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)**2/x,x)

[Out]

log(x)/2 - sin(2*a)*Si(2*b/x)/2 + cos(2*a)*Ci(2*b/x)/2

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 65 vs. \(2 (31) = 62\).
time = 4.77, size = 65, normalized size = 1.76 \begin {gather*} \frac {b \cos \left (2 \, a\right ) \operatorname {Ci}\left (-2 \, a + \frac {2 \, {\left (a x + b\right )}}{x}\right ) + b \sin \left (2 \, a\right ) \operatorname {Si}\left (2 \, a - \frac {2 \, {\left (a x + b\right )}}{x}\right ) - b \log \left (-a + \frac {a x + b}{x}\right )}{2 \, b} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(a+b/x)^2/x,x, algorithm="giac")

[Out]

1/2*(b*cos(2*a)*cos_integral(-2*a + 2*(a*x + b)/x) + b*sin(2*a)*sin_integral(2*a - 2*(a*x + b)/x) - b*log(-a +
 (a*x + b)/x))/b

________________________________________________________________________________________

Mupad [F]
time = 0.00, size = -1, normalized size = -0.03 \begin {gather*} \int \frac {{\sin \left (a+\frac {b}{x}\right )}^2}{x} \,d x \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(a + b/x)^2/x,x)

[Out]

int(sin(a + b/x)^2/x, x)

________________________________________________________________________________________